﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using System.Data.Linq;
using System.Linq.Expressions;
using System.Web.Services;

namespace SisTransportes.Apresentacao.WebForm.Usuario
{
    public partial class Default : Setting.PageApp
    {

        protected string Nome { set { value = txtNome.Text; } get { return txtNome.Text; } }
        protected string Email { set { value = txtEmail.Text; } get { return txtEmail.Text; } }

        
        protected void Page_Load(object sender, EventArgs e)
        {
            this.GridView_Load();
        }   


        
        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            this.GridView_Load();
        }



        protected void GridView_Load()
        {
            GridView1.DataSource = this.FiltraDados();
            GridView1.DataBind();
        }



        protected void FiltrarGridView_Load(object sender, EventArgs e)
        {
            this.GridView_Load();
        }

       
        protected List<Modelo.Usuario> FiltraDados()
        {
            string nome = this.Nome;
            string email = this.Email;

            List<Modelo.Usuario> dados = Mocks.UsuarioMock.Dados();

            IEnumerable query = from Modelo.Usuario _usuario in dados
                        where (_usuario.Nome.Contains(nome)) && 
                                (_usuario.Email.Contains(email))
                        select _usuario;

            return query.Cast<Modelo.Usuario>().ToList();
        }

       
    }

}